package com.fenghuo.map;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckedTextView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fenghuo.utils.Values;

import net.tsz.afinal.FinalActivity;
import net.tsz.afinal.annotation.view.ViewInject;

public class Ac_SearchByKind extends FinalActivity {

    @ViewInject(id = R.id.cht_chaoshi)
    CheckedTextView cht_chaoshi;
    @ViewInject(id = R.id.cht_shitang)
    CheckedTextView cht_shitang;
    @ViewInject(id = R.id.cht_atm)
    CheckedTextView cht_atm;
    @ViewInject(id = R.id.cht_gongjiaozhan)
    CheckedTextView cht_gongjiaozhan;
    @ViewInject(id = R.id.cht_tingchechang)
    CheckedTextView cht_tingchechang;
    @ViewInject(id = R.id.cht_yiwushi)
    CheckedTextView cht_yiwushi;

    @ViewInject(id = R.id.rela_search_chaoshi, click = "relaClick")
    RelativeLayout rel_chaoshi;
    @ViewInject(id = R.id.rela_search_atm, click = "relaClick")
    RelativeLayout rel_atm;
    @ViewInject(id = R.id.rela_search_gongjiao, click = "relaClick")
    RelativeLayout rel_gongjiao;
    @ViewInject(id = R.id.rela_search_shitang, click = "relaClick")
    RelativeLayout rel_shitang;
    @ViewInject(id = R.id.rela_search_tingchechang, click = "relaClick")
    RelativeLayout rel_tingchechang;
    @ViewInject(id = R.id.rela_search_yiwushi, click = "relaClick")
    RelativeLayout rel_yiwushi;

    @ViewInject(id = R.id.tv_back_searchbykind, click = "topClick")
    TextView tv_back;
    @ViewInject(id = R.id.iv_searchbykind, click = "topClick")
    ImageView img_ok;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_searchbykind);
    }

    public void relaClick(View v) {
        switch (v.getId()) {
            case R.id.rela_search_atm:
                cht_atm.setChecked(!cht_atm.isChecked());
                break;
            case R.id.rela_search_chaoshi:
                cht_chaoshi.setChecked(!cht_chaoshi.isChecked());
                break;
            case R.id.rela_search_gongjiao:
                cht_gongjiaozhan.setChecked(!cht_gongjiaozhan.isChecked());
                break;
            case R.id.rela_search_shitang:
                cht_shitang.setChecked(!cht_shitang.isChecked());
                break;
            case R.id.rela_search_tingchechang:
                cht_tingchechang.setChecked(!cht_tingchechang.isChecked());
                break;
            case R.id.rela_search_yiwushi:
                cht_yiwushi.setChecked(!cht_yiwushi.isChecked());
                break;

            default:
                break;
        }
    }

    public void topClick(View v) {
        switch (v.getId()) {
            case R.id.tv_back_searchbykind:
                Values.searchstrString = "";
                finish();
                break;
            case R.id.iv_searchbykind:
                String condition = "";
                if (cht_atm.isChecked())
                    condition += "ATM,";
                if (cht_chaoshi.isChecked())
                    condition += "超市,";
                if (cht_gongjiaozhan.isChecked())
                    condition += "公交站,";
                if (cht_shitang.isChecked())
                    condition += "食堂,";
                if (cht_tingchechang.isChecked())
                    condition += "停车场,";
                if (cht_yiwushi.isChecked())
                    condition += "医务室,";
                if (condition.length() > 0) {
                    condition = condition.substring(0, condition.length() - 1);
                    Values.searchstrString = condition;
                    finish();
                }
                break;
            default:
                break;
        }
    }

}
